<?php
/**
 * Created by PhpStorm.
 * User: CY
 * Date: 2018/3/2
 * Time: 13:45
 */

namespace app\api\controller\v1;

use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\MissException;
use think\Controller;
use app\api\model\Banner as BannerModel;

class Banner extends Controller
{
    /**
     * @url /banner/:id
     * @param $id
     * @return array|false|\PDOStatement|string|\think\Model
     * @throws MissException
     */
    public function getBanner($id){
        $validate = new IDMustBePositiveInt();
        $validate->goCheck();

        $banner = BannerModel::getBannerById($id);
        if(!$banner){
            throw new MissException([
                'msg' => '请求的banner不存在',
                'errorCode' => 40000
            ]);
        }

        return $banner;
    }
}